package com.common.controller;

import com.common.facebody.service.FaceBodyService;
import com.common.oss.service.OssService;
import com.common.sms.service.SmsSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private OssService ossService;

    @Autowired
    private FaceBodyService faceBodyService;

    @Autowired
    private SmsSendService smsSendService ;

    @PostMapping("/uploadFile")
    public String uploadFile(@RequestParam("file") MultipartFile multipartFile){
        return ossService.uploadMultipartFile(multipartFile);
    }

    @PostMapping("/uploadFileToPath")
    public String uploadFileToPath(@RequestParam("path") String path){
        return ossService.uploadFile(path);
    }

    @PostMapping("/searchFace")
    public Object searchFace(@RequestParam("file") MultipartFile multipartFile){
        String faceImgPath = ossService.uploadMultipartFile(multipartFile);
        return faceBodyService.searchFace("default",faceImgPath,1);
    }

    @GetMapping("/sms/smsSend")
    public Object smsSend(){
        return smsSendService.sendSms("18201612589","SMS_202545692",new HashMap<String, String>(){{
            put("code","134567");
        }});
    }

    @GetMapping("/sms/sendBatchSms")
    public Object sendBatchSms (){
        return smsSendService.sendBatchSms(
                new ArrayList<String>(){{
                    add("18201612589");
                    add("18201612589");
                }},
                "SMS_202545692",
                new ArrayList<Map<String, String>>(){{
                    add(new HashMap<String, String>(){{
                        put("code","134567");
                    }});
                    add(new HashMap<String, String>(){{
                        put("code","895645");
                    }});
                }}
        );
    }

}
